//import { AFSSTATUS } from '@/basePackage/pages/applyAfterSales/types'
import {
  ShopOrderItem,
  ORDERSTATUS,
  SHOPORDERSTATUS,
  SHOPITEMSTATUS,
  ShopOrder,
  PACKAGESTATUS,
  AFSSTATUS,
} from '@/views/personalcenter/order/myorder/types'
/* export const getStatus = (order: ApiOrder) => {
    const orderStatusHandler = orderStatusHandle[order.status]
    if (!orderStatusHandler.next) {
        return orderStatusHandler.desp
    }
    const shopOrders = order.shopOrders
} */

interface StatusHandle {
  desp: string
  next?: boolean
  toPaid?: boolean
  reason?: string
}

export const orderStatusHandle: Record<keyof typeof ORDERSTATUS, StatusHandle> = {
  UNPAID: {
    desp: '等待付款',
    toPaid: true,
  },
  PAID: {
    desp: '已支付',
    next: true,
  },
  BUYER_CLOSED: {
    desp: '已取消',
    reason: '用户关闭',
  },
  SYSTEM_CLOSED: {
    desp: '已取消',
    reason: '超时关闭',
  },
  SELLER_CLOSED: {
    desp: '已取消',
    reason: '商家关闭',
  },
  ACCOMPLISH: {
    desp: '已完成',
  },
  ON_DELIVERY: {
    desp: '待收货',
  },
}
export const isAllItemClosed = (items: Array<ShopOrderItem>): boolean => {
  return !items.find((item) => !shopOrderStatusHandle[item.status].close)
}

// export const getItemStatus = (item:ShopOrderItem)=>{
//   const itemHandler = shopOrderStatusHandle[item.status]
//   if(itemHandler.close){
//     return afsStatusHandle[item.afsStatus]
//   }
//   return packageStatusHandle[item.packageStatus]
// }

// export const afsStatusHandle: Record<keyof typeof AFSSTATUS, any> ={
//   NONE:{desp:""},
//   REFUND_REQUEST:{desp:""},
//   SYSTEM_REFUND_AGREE:{desp:""},
//   REFUND_AGREE:{desp:""},
//   REFUND_REJECT:{desp:""},
//   SYSTEM_RETURN_REFUND_AGREE:{desp:""},
//   REFUNDED:{desp:""},
//   SYSTEM_RETURNED_REFUND_CONFIRM:{desp:""},
//   RETURN_REFUND_REQUEST:{desp:""},
//   RETURN_REFUND_AGREE:{desp:""},
//   RETURN_REFUND_REJECT:{desp:""},
//   RETURNED_REFUND:{desp:""},
//   SYSTEM_CLOSED:{desp:""},
//   RETURNED_REFUND_CONFIRM:{desp:""},
//   RETURNED_REFUND_REJECT:{desp:""},
//   RETURNED_REFUNDED:{desp:""},
//   BUYER_CLOSED:{desp:""},
// }

export const packageStatusHandle: Record<keyof typeof PACKAGESTATUS, any> = {
  WAITING_FOR_DELIVER: { desp: '待发货', steps: 2 },
  WAITING_FOR_RECEIVE: { desp: '等待收货', color: '#71B247', track: true, Confirmreceipt: true, steps: 3 },
  BUYER_WAITING_FOR_COMMENT: { desp: '交易成功', color: '#ccc', track: true, evaluate: true, steps: 4 },
  SYSTEM_WAITING_FOR_COMMENT: { desp: '交易成功', color: '#ccc', track: true, evaluate: true, steps: 4 },
  BUYER_COMMENTED_COMPLETED: { desp: '交易成功', color: '#ccc', track: true, steps: 4 },
  SYSTEM_COMMENTED_COMPLETED: { desp: '交易成功', color: '#ccc', track: true, steps: 4 },
}
export const shopOrderStatusHandle: Record<keyof typeof SHOPITEMSTATUS, any> = {
  OK: {},
  CLOSED: { close: true },
}
